import { getCategoryList, getRank, getGuessLike, getFloor, getSelf } from '../../../Api/index.js'
// 首页请求
const homeAbout = {
  namespaced: true,
  actions: {
    // 获取分类列表
    async getCategoryList (context) {
      const result = await getCategoryList()
      if (result.code === 200) {
        context.commit('CHANGECATEGORYLIST', result)
      }
    },
    // 获取自身
    async getSelf ({ commit }) {
      const result = await getSelf()
      commit('GETSELF', result)
    },
    // 获取排行列表
    async getRank (context) {
      const getRanks = await getRank()
      context.commit('GETRANKS', getRanks.data)
    },
    // 获取猜你喜欢列表
    async guessLike ({ commit }) {
      const { data } = await getGuessLike()
      commit('GUESSLIKE', data)
    },
    // 获取Floor区
    async getFloor ({ commit }) {
      const { data } = await getFloor()
      commit('GETFLOOR', data)
    }
  },
  mutations: {
    // 移除phone
    removePhone (state) {
      state.phone = ''
    },
    // 获取分类列表
    CHANGECATEGORYLIST (state, result) {
      state.CategoryList = result.data
    },
    // 获取排行列表
    GETRANKS (state, result) {
      state.Ranks = result
    },
    // 获取猜你喜欢列表
    GUESSLIKE (state, result) {
      state.GuessLike = result
    },
    // 获取Floor区
    GETFLOOR (state, result) {
      state.Floors = result
    },
    // 获取自身
    GETSELF (state, val) {
      state.phone = val.user
    }
  },
  state: {
    phone: '',
    // 获取分类列表
    CategoryList: [],
    // 获取排行列表
    Ranks: [],
    // 获取猜你喜欢列表
    GuessLike: [],
    // 获取Floor区
    Floors: []
  }
}
export default homeAbout
